//
//  ByViewUserIndexBranchLocation.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/14.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByViewUserIndexBranchLocation.h"

@implementation ByViewUserIndexBranchLocation
{
    UIImageView *_locationImg;
    UILabel     *_currentLabel;
    UILabel     *_addressLabel;
    UIButton    *_reLocationButton;
}
- (instancetype)init{
    if (self == [super init]) {
        [self createViews];
    }
    return self;
}

#pragma mark - 创建视图
- (void)createViews{
    _locationImg = [[UIImageView alloc] init];
    [self addSubview:_locationImg];
    [_locationImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(10));
        make.top.equalTo(@(10));
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    _locationImg.image = [UIImage imageNamed:@"Index_location"];
    
    _currentLabel = [[UILabel alloc] init];
    [self addSubview:_currentLabel];
    CGFloat width = [@"当前定位" getSizeOfString:14].width + 5;
    [_currentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_locationImg.mas_right).offset(5);
        make.top.equalTo(@(10));
        make.size.mas_equalTo(CGSizeMake(width, 20));
    }];
    _currentLabel.text = @"当前定位";
    _currentLabel.font = FONT(14);
    _currentLabel.textColor = BY_THEME_COLOR;
    
    _reLocationButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:_reLocationButton];
    width = [@"重新定位" getSizeOfString:14].width + 30;
    [_reLocationButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-10));
        make.top.equalTo(@(5));
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    [_reLocationButton setTitle:@"重新定位" forState:UIControlStateNormal];
    [_reLocationButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _reLocationButton.titleLabel.font = FONT(14);
    _reLocationButton.layer.cornerRadius = 30 / 2;
    [_reLocationButton setBackgroundColor:BY_THEME_COLOR];
    
    _addressLabel = [[UILabel alloc] init];
    [self addSubview:_addressLabel];
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_currentLabel.mas_right).offset(5);
        make.top.equalTo(@(10));
        make.right.equalTo(_reLocationButton.mas_left).offset(-5);
        make.height.equalTo(@(20));
    }];
    _addressLabel.font = FONT(14);
    
}

- (void)setAddress:(NSString *)address{
    _address = address;
    _addressLabel.text = _address;
}

@end
